home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Dynamic Controls"
- ClientHeight = 4020
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- Height = 4425
- Left = 1035
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 4020
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin CommandButton Command3
- Caption = "End"
- Height = 495
- Left = 5880
- TabIndex = 3
- Top = 240
- Width = 1215
- End
- Begin TextBox Text1
- Height = 855
- Index = 0
- Left = 240
- TabIndex = 0
- Text = "Text1"
- Top = 240
- Width = 1455
- End
- Begin CommandButton Command1
- Caption = "Add Text Box"
- Height = 375
- Left = 240
- TabIndex = 1
- Top = 2640
- Width = 1575
- End
- Begin CommandButton Command2
- Caption = "Delete Text Box"
- Enabled = 0 'False
- Height = 375
- Left = 240
- TabIndex = 2
- Top = 3120
- Width = 1575
- End
- Option Explicit
- Dim TextBoxCount As Integer
- Dim RepeatFactor As Integer
- Sub Command1_Click ()
- Dim myRed As Integer, myBlue As Integer, myGreen As Integer
- myRed = Rnd * 255
- myGreen = Rnd * 255
- myBlue = Rnd * 255
- 'Get the next array index number
- TextBoxCount = TextBoxCount + 1
- 'Create the new control dynamically
- Load text1(TextBoxCount)
- 'Set the position for top left corner of the new control
- 'so it won't fall on top of previous control
- If text1(TextBoxCount - 1).Top > .7 * form1.Height Then
- text1(TextBoxCount).Move text1(0).Left + RepeatFactor * 1600, text1(0).Top
- RepeatFactor = RepeatFactor + 1
- Else
- text1(TextBoxCount).Move text1(TextBoxCount - 1).Left + 200, text1(TextBoxCount - 1).Top + 200
- End If
- 'Give it a random color
- text1(TextBoxCount).BackColor = RGB(myRed, myGreen, myBlue)
- 'Now, display the new control
- text1(TextBoxCount).Visible = True
- command2.Enabled = True
- End Sub
- Sub Command2_Click ()
- Unload text1(TextBoxCount)
- TextBoxCount = TextBoxCount - 1
- If TextBoxCount = 0 Then
- command2.Enabled = False
- End If
- End Sub
- Sub Command3_Click ()
- End
- End Sub
- Sub Form_Load ()
- Randomize Timer
- RepeatFactor = 1
- End Sub
-